﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BookReader
{
    class encCommand:ICommand
    {
        void ICommand.Execute(string[] param)
        {
            if (param != null && param.Length == 1)
            {
                switch (param[0].ToLower())
                {
                    case "utf8":
                        StaticData.encoding = Encoding.UTF8;
                        break;
                    case "unicode":
                        StaticData.encoding = Encoding.Unicode;
                        break;
                    case "ascii":
                        StaticData.encoding = Encoding.ASCII;
                        break;
                    case "default":
                    default:
                        StaticData.encoding = Encoding.Default;
                        break;
                }
                Console.WriteLine("编码变更为" + StaticData.encoding.EncodingName);
            }
            else
            {
                Console.WriteLine("参数错误："+((ICommand)this).Help());
            }
        }

        string ICommand.Help()
        {
            return "enc命令：变更编码方式 格式：enc 编码名称  可选项 utf8,unicode,ascii,default";
        }
    }
}
